package de.ubschmidt.capi;

import java.nio.ByteBuffer;

/**
 *
 */
public class InfoInd
        extends CapiPassiveMessage
        implements PlciAccessor {

    private static final int OFFSET_PLCI = OFFSET_MESSAGE;
    private static final int OFFSET_INFO_NUMBER = OFFSET_MESSAGE + SIZE_OF_PLCI;
    private static final int OFFSET_INFO_STRUCT = OFFSET_INFO_NUMBER + 2;

    /**
     *
     * @param byteBuffer
     */
    public InfoInd(final ByteBuffer byteBuffer) {
        super(byteBuffer);
    }

    /** {@inheritDoc} */
    public int getPlci() {
        return getByteBuffer().getInt(OFFSET_PLCI);
    }

    /**
     *
     * @return
     */
    public short getInfoNumber() {
        return getByteBuffer().getShort(OFFSET_INFO_NUMBER);
    }

    public CapiStruct getInfoElement() {
        ByteBuffer byteBuffer = getByteBuffer();
        byteBuffer.position(OFFSET_INFO_STRUCT);

        return new CapiStruct(byteBuffer);
    }

    /** {@inheritDoc} */
    @Override
    public String toString() {
        String s = String.format(

                "%s[%s plci=0x%08x info#=0x%04x info=%s]",
                getClass().getSimpleName(),
                super.toString(),
                getPlci(),
                getInfoNumber(),getInfoElement());

        return s;
    }

}
